perm filename SEXP[F75,JMC] blob sn#179976 filedate 1975-10-05 generic text, type T, neo UTF8
00100	Writing LISP programs as S-expressions
00200	
00300	
00400		The notation we have developed in this chapter for writing
00500	LISP functions is optimized for the textbook presentation of
00600	LISP functions.  Thus it uses different type fonts for different
00700	kinds of entities and corresponds to the ALGOL publication language
00800	in so far as the languages allow.  Clearly it is not a suitable
00900	notation for computer input, because computer input devices do
01000	not permit type font distinctions, and even if they did, these
01100	distinctions are a nuisance to the hand even though they are a
01200	convenience to the eye.
01300	
01400		 Unfortunately, there is not yet a standard notation
01500	suitable for computer input that is convenient to write.  A lot
01600	depends on what characters are present on keyboards.  It is not
01700	even clear whether the distinction between lower and upper case
01800	characters is worth using on input.  MLISP and RLISP are two
01900	systems that provide reasonably convenient notations.
02000	However, there is yet another need for a notation for LISP programs
02100	that has given rise to yet another notation - the need to represent
02200	LISP programs as LISP data.
02300	
02400		As we shall see, it is convenient to use LISP programs to
02500	create other LISP programs, to compile them, to optimize them, and
02600	to interpret them.  For this purpose,
02700	
02800	
02900		Besides the textbook notation for LISP functions that has
03000	been introduced in the preceding sections, we also need a representation
03100	of LISP programs as LISP data - i.e. as lists - so that LISP
03200	programs can be written to interpret, compile, generate, and optimize
03300	LISP programs.  This is called S-expression notation, and it it is
03400	also used for human writing of LISP programs although it is not very
03500	convenient to read and write.  Here it is:
03600	
03700		LISP programs are built up from S-expressions, variables
03800	and function symbols by function application, by the formation
03900	of conditional expressions and lambda expressions, by label, and
04000	by making function definitions.  The S-expression notation can
04100	be described by telling how all these things are represented.
04200	
04300		1. Variables are represented by non-numeric atoms, and
04400	function symbols are also atoms.  Thus we often use X, Y and
04500	GRAPH for variables and ALT, REVERSE, and UNION for functions.
04600	
04700		2. The symbols for the standard LISP functions are
04800	CAR for %3a%1, CDR for %3d%1, CONS for %2cons%1, ATOM for %3at%1
04900	and EQ for %3eq%1.